<template>
  <div v-loading="loading">
    <el-form
      ref="form"
      :model="form"
      :rules="rules"
      label-width="120px"
      class="dataForm"
    >
      <el-row>
        <!-- <el-col :span="8">
          <el-form-item :label="$t('版本名字')" prop="versionName">
            <el-input
              v-model="form.versionType"
              :placeholder="$t('版本名字')"
              disabled
            />
          </el-form-item>
        </el-col> -->
        <el-col :span="8">
          <el-form-item :label="$t('土地面积(平方米)')" prop="acreage">
            <el-input v-model="form.acreage" :placeholder="$t('土地面积')" @input="calcArea()" />
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item :label="$t('容积率')" prop="plotRatio">
            <el-input
              v-model="form.plotRatio"
              :placeholder="$t('容积率')"
              show-word-limit
              @input="calcArea()"
            />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item :label="$t('计算面积(平方米)')" prop="calculateArea">
            <el-input
              v-model="form.calculateArea"
              :placeholder="$t('土地面积*容积率')"
              show-word-limit
            />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item :label="$t('可售面积(平方米)')" prop="vendibilityArea">
            <el-input
              v-model="form.vendibilityArea"
              :placeholder="$t('可售面积')"
              show-word-limit
              @input="calcPrice()"
              @change="calcp"
            />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item :label="$t('总货值')+ $t('(亿元)')" prop="totalValue">
            <!-- <el-input
              v-model="form.totalValue"
              :placeholder="$t('总货值')"
              show-word-limit
            /> -->
            <Money v-model="form.totalValue" :placeholder="$t('总货值')" unit="y" @change="calcPrice()" />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item :label="$t('单方售价(元/平方米)')" prop="onePrice">
            <Money v-model="form.onePrice" :placeholder="$t('单方售价')" />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item :label="$t('土地成本(亿元)')" prop="acreageCost">
            <Money v-model="form.acreageCost" :placeholder="$t('土地成本')" unit="y" @change="calcp()" />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item :label="$t('土地调整(亿元)')" prop="acreageAdjust">
            <Money v-model="form.acreageAdjust" :placeholder="$t('土地调整')" unit="y" @change="calcp()" />
          </el-form-item>
        </el-col>
        <!-- <el-col :span="12">
          <el-form-item :label="$t('不可售面积')" prop="noVendibilityArea">
            <el-input v-model="form.noVendibilityArea" :placeholder="$t('不可售面积')" show-word-limit maxlength="25" />
          </el-form-item>
        </el-col> -->
        <!-- <el-col :span="12">
          <el-form-item :label="$t('总套数')" prop="totalNumber">
            <el-input v-model="form.totalNumber" :placeholder="$t('总套数')" show-word-limit />
          </el-form-item>
        </el-col>
    <el-col :span="24">
        <el-form-item :label="$t('原始地价')" prop="originalPrice">
            <Money v-model="form.originalPrice" :placeholder="$t('原始地价')" />
        </el-form-item>
    </el-col>
    <el-col :span="24">
        <el-form-item :label="$t('综合地价')" prop="synthesisPrice">
            <Money v-model="form.synthesisPrice" :placeholder="$t('综合地价')" />
        </el-form-item>
    </el-col>-->
        <el-col :span="8">
          <el-form-item :label="$t('除地价外直接投资(亿元)')" prop="directInvestment">
            <Money v-model="form.directInvestment" :placeholder="$t('除地价外直接投资')" unit="y" />
            <!-- <el-input v-model="form.directInvestment" :placeholder="$t('除地价外直接投资')" /> -->
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item
            :label="$t('可售楼面价(元/平方米)')"
            prop="vendibilityPrice"
          >
            <el-input
              v-model="form.vendibilityPrice"
              :placeholder="$t('可售楼面价')"
              show-word-limit
            />
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item :label="$t('总成本(亿元)')" prop="totalCost">
            <Money
              v-model="form.totalCost"
              :placeholder="$t('总成本')"
              unit="y"
              @change="calcCost()"
            />
          </el-form-item>
        </el-col>

        <!-- <el-col :span="12">
          <el-form-item :label="$t('除地价外直接投资')" prop="exceptDirectInvestment">
            <el-input v-model="form.exceptDirectInvestment" :placeholder="$t('除地价外直接投资')" show-word-limit maxlength="127" />
          </el-form-item>
        </el-col>
    <el-col :span="24">
        <el-form-item :label="$t('营销费用')" prop="marketingCost">
            <Money v-model="form.marketingCost" :placeholder="$t('营销费用')" />
        </el-form-item>
    </el-col>
    <el-col :span="24">
        <el-form-item :label="$t('管理费用')" prop="manageCost">
            <Money v-model="form.manageCost" :placeholder="$t('管理费用')" />
        </el-form-item>
    </el-col>
    <el-col :span="24">
        <el-form-item :label="$t('财务费用')" prop="financeCost">
            <Money v-model="form.financeCost" :placeholder="$t('财务费用')" />
        </el-form-item>
    </el-col> -->

        <el-col :span="8">
          <el-form-item :label="$t('单方成本(元/平方米)')" prop="oneCost">
            <Money v-model="form.oneCost" :placeholder="$t('单方成本')" />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item :label="$t('开发贷款金额(亿元)')" prop="developLoans">
            <Money v-model="form.developLoans" :placeholder="$t('开发贷款')" unit="y" />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item :label="$t('资金峰值(亿元)')" prop="capitalPeak">
            <Money v-model="form.capitalPeak" :placeholder="$t('资金峰值')" unit="y" />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item :label="$t('税后现金利润(亿元)')" prop="atCashProfit">
            <Money
              v-model="form.atCashProfit"
              :placeholder="$t('税后现金利润')"
              unit="y"
            />
          </el-form-item>
        </el-col>
        <!-- <el-col :span="24">
        <el-form-item :label="$t('税后资产(亿元)')" prop="atProperty">
            <Money v-model="form.atProperty" :placeholder="$t('税后资产')" />
        </el-form-item>
    </el-col> -->
        <el-col :span="8">
          <el-form-item :label="$t('税后总利润(亿元)')" prop="atTotalProfit">
            <Money
              v-model="form.atTotalProfit"
              :placeholder="$t('税后总利润')"
              unit="y"
            />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item :label="$t('税前成本利润率(%)')" prop="preAtCostProfit">
            <el-input
              v-model="form.preAtCostProfit"
              :placeholder="$t('税前成本利润率')"
              show-word-limit
            />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item :label="$t('收回股东投入期限(月)')" prop="takeBackTime">
            <el-input
              v-model="form.takeBackTime"
              :placeholder="$t('收回股东投入期限(月)')"
            />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item :label="$t('自有资金IRR')" prop="irr">
            <Money v-model="form.irr" :placeholder="$t('自有资金IRR')" />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item :label="$t('投资回报倍数')" prop="roi">
            <Money v-model="form.roi" :placeholder="$t('投资回报倍数')" />
          </el-form-item>
        </el-col>
        <!-- <el-col :span="24">
        <el-form-item :label="$t('项目层面达到盈亏平衡点时均价')" prop="dealAveragePrice">
            <Money v-model="form.dealAveragePrice" :placeholder="$t('项目层面达到盈亏平衡点时均价')" />
        </el-form-item>
    </el-col>
    <el-col :span="24">
        <el-form-item :label="$t('基金层面达到盈亏平衡点时均价')" prop="fundAveragePrice">
            <Money v-model="form.fundAveragePrice" :placeholder="$t('基金层面达到盈亏平衡点时均价')" />
        </el-form-item>
    </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('基金层面实现8%门槛时均价')" prop="fundAspect">
            <el-input v-model="form.fundAspect" :placeholder="$t('基金层面实现8%门槛时均价')" show-word-limit maxlength="127" />
          </el-form-item>
        </el-col> -->
        <el-col :span="24">
          <el-form-item :label="$t('备注')">
            <el-input v-model="form.remark" type="textarea" />
          </el-form-item>
        </el-col>
        <!-- ---------------------------业态明细 -------------------------------------->
        <el-col :span="24">
          <div class="area-header">
            <span class="area-header-title">{{ $t("业态明细") }}</span>
          </div>
          <el-table
            :data="form.activitiesList"
            style="width: 100%"
            class="nowrapTable formTable"
            border
          >
            <el-table-column label="业态类型" align="center">
              <template slot="header" slot-scope="{}">
                <i style="color: #ff4949; margin-right: 4px">*</i>
                <span>{{ $t("业态类型") }}</span>
              </template>
              <template slot-scope="scope">
                <el-form-item
                  :prop="'activitiesList.' + scope.$index + '.activitiesType'"
                  :rules="activitiesListRules.activitiesType"
                >
                  <dictSelect
                    v-model="scope.row.activitiesType"
                    :clearable="true"
                    dictionary="type_formats"
                    @change="changeUnit"
                  />
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column label="可售面积(平方米)" align="center">
              <template slot="header" slot-scope="{}">
                <i style="color: #ff4949; margin-right: 4px">*</i>
                <span>{{ $t(unit) }}</span>
              </template>
              <template slot-scope="scope">
                <el-form-item
                  :prop="'activitiesList.' + scope.$index + '.availableArea'"
                  :rules="activitiesListRules.availableArea"
                >
                  <el-input
                    v-model="scope.row.availableArea"
                    :placeholder="$t(unit)"
                    @input="tCalcArea(scope.row)"
                    @change="calcPrice"
                  />
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column label="单价(元/平方米)" align="center">
              <template slot="header" slot-scope="{}">
                <i style="color: #ff4949; margin-right: 4px">*</i>
                <span>{{ $t("单价(元/平方米)") }}</span>
              </template>
              <template slot-scope="scope">
                <el-form-item
                  :prop="'activitiesList.' + scope.$index + '.price'"
                  :rules="activitiesListRules.price"
                >
                  <el-input
                    v-model="scope.row.price"
                    :placeholder="$t('单价(元/平方米)')"
                    @input="tCalcArea(scope.row)"
                  />
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column label="总货值(亿元)" align="center">
              <template slot="header" slot-scope="{}">
                <i style="color: #ff4949; margin-right: 4px">*</i>
                <span>{{ $t("总货值(亿元)") }}</span>
              </template>
              <template slot-scope="scope">
                <el-form-item
                  :prop="'activitiesList.' + scope.$index + '.totalPrice'"
                  :rules="activitiesListRules.totalPrice"
                >
                  <!-- <el-input
                    v-model="scope.row.totalPrice"
                    :placeholder="$t('总货值(亿元)')"
                  /> -->
                  <Money v-model="scope.row.totalPrice" :placeholder="$t('总货值(亿元)')" unit="y" />
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column label="备注" align="center">
              <template slot-scope="scope">
                <el-form-item>
                  <el-input
                    v-model="scope.row.remark"
                    type="textarea"
                    :placeholder="$t('备注')"
                    maxlength="2000"
                    class="fileTextarea"
                  />
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column
              :label="$t('操作')"
              align="center"
              class-name="small-padding fixed-width"
              width="140"
            >
              <template slot-scope="scope">
                <!-- <el-button
                  size="small"
                  type="text"
                  icon="el-icon-edit"
                  @click="updateHandle(scope.row)"
                >{{ $t("编辑") }}</el-button> -->
                <el-button
                  size="small"
                  type="text"
                  icon="el-icon-delete"
                  @click="delActivitiesTypeHandle(scope.$index, scope.row)"
                >{{ $t("删除") }}</el-button>
              </template>
            </el-table-column>
          </el-table>
          <div class="tol">
            <el-button
              type="primary"
              icon="el-icon-plus"
              size="mini"
              @click="addActivities"
            >{{ $t("添加") }}</el-button>
          </div>
        </el-col>
        <!-- ---------------------------股东资产明细 -------------------------------------->
        <el-col :span="24">
          <div class="area-header" style="margin-top: 10px">
            <span class="area-header-title">{{ $t("股东资产明细") }}</span>
          </div>
          <el-table
            :data="form.shareholderList"
            style="width: 100%"
            class="nowrapTable formTable"
            border
          >
            <el-table-column label="业态类型" align="center">
              <template slot="header" slot-scope="{}">
                <i style="color: #ff4949; margin-right: 4px">*</i>
                <span>{{ $t("业态类型") }}</span>
              </template>
              <template slot-scope="scope">
                <el-form-item
                  :prop="'shareholderList.' + scope.$index + '.activitiesType'"
                  :rules="shareholderListRules.activitiesType"
                >
                  <dictSelect
                    v-model="scope.row.activitiesType"
                    :clearable="true"
                    dictionary="type_formats"
                    @change="changeUnit2"
                  />
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column prop="oneselfType" label="自持类型" align="center">
              <template slot="header" slot-scope="{}">
                <i style="color: #ff4949; margin-right: 4px">*</i>
                <span>{{ $t("自持类型") }}</span>
              </template>
              <template slot-scope="scope">
                <el-form-item
                  :prop="'shareholderList.' + scope.$index + '.oneselfType'"
                  :rules="shareholderListRules.oneselfType"
                >
                  <dictSelect
                    v-model="scope.row.oneselfType"
                    :clearable="true"
                    dictionary="oneself_type"
                  />
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column prop="area" label="面积(㎡)" align="center">
              <template slot="header" slot-scope="{}">
                <i style="color: #ff4949; margin-right: 4px">*</i>
                <span>{{ $t(unitA) }}</span>
              </template>
              <template slot-scope="scope">
                <el-form-item
                  :prop="'shareholderList.' + scope.$index + '.area'"
                  :rules="shareholderListRules.area"
                >
                  <el-input
                    v-model="scope.row.area"
                    :placeholder="$t(unitA)"
                    show-word-limit
                  />
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column
              prop="totalCost"
              label="总成本(亿元)"
              align="center"
            >
              <template slot="header" slot-scope="{}">
                <i style="color: #ff4949; margin-right: 4px">*</i>
                <span>{{ $t("总成本(亿元)") }}</span>
              </template>
              <template slot-scope="scope">
                <el-form-item
                  :prop="'shareholderList.' + scope.$index + '.totalCost'"
                  :rules="shareholderListRules.totalCost"
                >
                  <el-input
                    v-model="scope.row.totalCost"
                    :placeholder="$t('总成本(亿元)')"
                    show-word-limit
                  />
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column
              :label="$t('操作')"
              align="center"
              class-name="small-padding fixed-width"
              width="140"
            >
              <template slot-scope="scope">
                <!-- <el-button
                  size="small"
                  type="text"
                  icon="el-icon-edit"
                  @click="updateHandle(scope.row)"
                >{{ $t("编辑") }}</el-button> -->
                <el-button
                  size="small"
                  type="text"
                  icon="el-icon-delete"
                  @click="delShareholderHandle(scope.$index, scope.row)"
                >{{ $t("删除") }}</el-button>
              </template>
            </el-table-column>
          </el-table>
          <div class="tol">
            <el-button
              type="primary"
              icon="el-icon-plus"
              size="mini"
              @click="addShareholder"
            >{{ $t("添加") }}</el-button>
          </div>
        </el-col>
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer" style="text-align: right">
      <!--保存 取消按钮-->
      <save-btn has-permi="system:index" />
    </div>
  </div>
</template>

<script>
import {
  saveDealIndex,
  getDealIndex,
  dealIndexActivities,
  dealIndexDetails
} from '@/api/deal/estate/index/dealIndex'
export default {
  data() {
    return {
      // 表单参数
      form: {
        dealId: '',
        activitiesList: [], // 业态明细
        shareholderList: [] // 股东明细
      },
      unit: '可售面积(平方米)',
      unitA: '面积(㎡)',
      // 遮罩层
      loading: false,
      activitiesOptionList: [],
      oneSelfOptionList: [], // 自持类型
      // 表单校验
      rules: {
        acreage: [
          { required: true, message: this.$t('必填信息'), trigger: 'blur' }
        ],
        plotRatio: [
          { required: true, message: this.$t('必填信息'), trigger: 'blur' }
        ],
        calculateArea: [
          { required: true, message: this.$t('必填信息'), trigger: 'blur' }
        ],
        acreageCost: [
          { required: true, message: this.$t('必填信息'), trigger: 'blur' }
        ],
        vendibilityArea: [
          { required: true, message: this.$t('必填信息'), trigger: 'blur' }
        ],
        acreageAdjust: [
          { required: true, message: this.$t('必填信息'), trigger: 'blur' }
        ],
        vendibilityPrice: [
          { required: true, message: this.$t('必填信息'), trigger: 'blur' }
        ],
        totalValue: [
          { required: true, message: this.$t('必填信息'), trigger: 'blur' }
        ],
        totalCost: [
          { required: true, message: this.$t('必填信息'), trigger: 'blur' }
        ],
        onePrice: [
          { required: true, message: this.$t('必填信息'), trigger: 'blur' }
        ],
        oneCost: [
          { required: true, message: this.$t('必填信息'), trigger: 'blur' }
        ],
        developLoans: [
          { required: true, message: this.$t('必填信息'), trigger: 'blur' }
        ],
        capitalPeak: [
          { required: true, message: this.$t('必填信息'), trigger: 'blur' }
        ],
        atCashProfit: [
          { required: true, message: this.$t('必填信息'), trigger: 'blur' }
        ],
        atTotalProfit: [
          { required: true, message: this.$t('必填信息'), trigger: 'blur' }
        ],
        preAtCostProfit: [
          { required: true, message: this.$t('必填信息'), trigger: 'blur' }
        ],
        takeBackTime: [
          { required: true, message: this.$t('必填信息'), trigger: 'blur' }
        ],
        irr: [
          { required: true, message: this.$t('必填信息'), trigger: 'blur' }
        ],
        roi: [
          { required: true, message: this.$t('必填信息'), trigger: 'blur' }
        ],
        directInvestment: [
           { required: true, message: this.$t('必填信息'), trigger: 'blur' }
        ]
      },
      shareholderListRules: {
        activitiesType: [
          { required: true, message: this.$t('必填信息'), trigger: 'blur' }
        ],
        oneselfType: [
          { required: true, message: this.$t('必填信息'), trigger: 'blur' }
        ],
        totalCost: [
          { required: true, message: this.$t('必填信息'), trigger: 'blur' }
        ],
        area: [
          { required: true, message: this.$t('必填信息'), trigger: 'blur' }
        ]
      },
      activitiesListRules: {
        activitiesType: [
          { required: true, message: this.$t('必填信息'), trigger: 'blur' }
        ],
        availableArea: [
          { required: true, message: this.$t('必填信息'), trigger: 'blur' }
        ],
        price: [
          { required: true, message: this.$t('必填信息'), trigger: 'blur' }
        ],
        totalPrice: [
          { required: true, message: this.$t('必填信息'), trigger: 'blur' }
        ]
      }
    }
  },
  watch: {
    //  form:{
    //    handler(newV, oldV){
    //       if (newV.plotRatio  && newV.acreage) { //计算面积
    //       const res= newV.plotRatio * newV.acreage
    //       this.form.calculateArea =res.toFixed(2);
    //      }
    //    },
    //    deep:true,
    // }
  },
  created() {
    this.getDicts('type_formats').then((response) => {
      this.activitiesOptionList = response.data
    })
    this.getDicts('oneself_type').then((response) => {
      this.oneSelfOptionList = response.data
    })
    this.form.dealId = this.$route.query.id
  },
  methods: {
    // 初始化数据
    init(id, type) {
      this.loading = true
      if (id != null && id !== undefined && id !== '') {
        getDealIndex(id, type).then((response) => {
          this.form = response.data
          this.form.versionType = type
          this.loading = false
        })
      } else {
        this.reset()
        this.loading = false
      }
    },
    // 表单重置
    reset() {
      this.form = {
        id: undefined,

        versionName: undefined,

        isAutoUpdate: undefined,

        acreageCost: undefined,

        acreageAdjust: undefined,

        acreage: undefined,

        plotRatio: undefined,

        calculateArea: undefined,

        vendibilityArea: undefined,

        noVendibilityArea: undefined,

        totalNumber: undefined,

        originalPrice: undefined,

        synthesisPrice: undefined,

        directInvestment: undefined,

        vendibilityPrice: undefined,

        totalValue: undefined,

        exceptDirectInvestment: undefined,

        marketingCost: undefined,

        manageCost: undefined,

        financeCost: undefined,

        totalCost: undefined,

        onePrice: undefined,

        oneCost: undefined,

        developLoans: undefined,

        capitalPeak: undefined,

        atCashProfit: undefined,

        atProperty: undefined,

        atTotalProfit: undefined,

        preAtCostProfit: undefined,

        takeBackTime: undefined,

        irr: undefined,

        roi: undefined,

        dealAveragePrice: undefined,

        fundAveragePrice: undefined,

        fundAspect: undefined,

        remark: undefined,

        createBy: undefined,

        createTime: undefined,
        activitiesList: [], // 业态明细

        shareholderList: [] // 股东明细
      }
      this.resetForm('form')
    },
    // 取消按钮
    cancel() {
      this.$parent.$parent.formOpen = false
      this.$parent.$parent.reset()
    },
    // 关闭form页面
    closeForm() {
      // 关闭form页面遮罩层
      this.loading = false
      // 关闭form页面
      if (this.$parent.$parent.formOpen !== undefined) {
        this.$parent.$parent.formOpen = false
      }
      // 刷新list页面
      if (this.$parent.$parent.getList !== undefined) {
        this.$parent.$parent.getList()
      }
    },
    /** 提交按钮 */
    submitForm: function() {
      this.$refs['form'].validate((valid) => {
        if (valid) {
          this.loading = true
          this.form.dealId = this.$route.query.id
          saveDealIndex(this.form).then((response) => {
            if (response.code === 200) {
              this.msgSuccess(this.$t('保存成功'))
              this.closeForm()
            } else {
              this.msgError(response.msg)
            }
            this.loading = false
          })
        } else {
          this.locationError(document)
        }
      })
    },
    // 添加业态明细
    addActivities() {
      const row = {
        id: undefined,
        activitiesType: '',
        availableArea: '',
        price: '',
        totalPrice: '',
        remark: ''
      }
      if (!(this.form.activitiesList instanceof Array)) {
        this.$set(this.form, 'activitiesList', [])
      }
      this.$nextTick(() => {
        this.form.activitiesList.push(row)
      })
    },
    // 添加股东明细
    addShareholder() {
      const row = {
        id: undefined,
        activitiesType: '',
        oneselfType: '',
        area: '',
        totalCost: ''
      }
      if (!(this.form.shareholderList instanceof Array)) {
        this.$set(this.form, 'shareholderList', [])
      }
      this.$nextTick(() => {
        this.form.shareholderList.push(row)
      })
    },
    // 删除业态明细
    delActivitiesTypeHandle(index, row) {
      const id = row.id
      if (id !== undefined && id !== '' && id != null) {
        this.$confirm(this.$t('是否确认删除?'), this.$t('警告'), {
          confirmButtonText: this.$t('确定'),
          cancelButtonText: this.$t('取消'),
          type: 'warning'
        })
          .then(() => {
            // 调用接口
            dealIndexActivities(id)
            this.form.activitiesList.splice(index, 1)
            return this.msgSuccess(this.$t('删除成功'))
          })
          .catch(function() {})
      } else {
        this.form.activitiesList.splice(index, 1)
      }
    }, // 删除股东明细
    delShareholderHandle(index, row) {
      const id = row.id
      if (id !== undefined && id !== '' && id != null) {
        this.$confirm(this.$t('是否确认删除?'), this.$t('警告'), {
          confirmButtonText: this.$t('确定'),
          cancelButtonText: this.$t('取消'),
          type: 'warning'
        })
          .then(() => {
            // 调用接口
            dealIndexDetails(id)
            this.form.shareholderList.splice(index, 1)
            return this.msgSuccess(this.$t('删除成功'))
          })
          .catch(function() {})
      } else {
        this.form.shareholderList.splice(index, 1)
      }
    },
    calcArea() {
      // 计算面积
      if (this.form.plotRatio && this.form.acreage) {
        const res = this.form.plotRatio * this.form.acreage
        this.form.calculateArea = res.toFixed(2)
      }
    },
    calcPrice() {
      // 单方售价
      if (this.form.totalValue && this.form.vendibilityArea) {
        const res = this.form.totalValue / this.form.vendibilityArea
        console.log('总货值', this.form.totalValue)
        console.log(res)
        this.form.onePrice = res.toFixed(2)
      }
    },
    calcp() {
      // console.log(this.form.acreageCost, this.form.acreageAdjust, this.form.vendibilityArea)

         // 可售楼面价  土地成本+土地成本调整项）*1亿/可售面积
       if (this.form.acreageCost && this.form.acreageAdjust && this.form.vendibilityArea) {
           const pa = parseFloat(this.form.vendibilityArea)
             const res = (this.form.acreageCost + this.form.acreageAdjust) / pa
            this.form.vendibilityPrice = res.toFixed(2)
       }
    },
    calcCost() {
         // 单方成本
      if (this.form.totalCost && this.form.vendibilityArea) {
        const res = this.form.totalCost / this.form.vendibilityArea
        this.form.oneCost = res.toFixed(2)
      }
    },
    tCalcArea(row) {
      if (row.availableArea && row.price) {
        row.totalPrice = row.availableArea * row.price
    }
 },
  changeUnit(val) {
      console.log(val)
      if (val === 'CW') {
          this.unit = '可售面积(个)'
      } else {
         this.unit = '可售面积(平方米)'
      }
  },
  changeUnit2(val) {
    console.log(val)
    if (val === 'CW') {
          this.unitA = '面积(个)'
      } else {
         this.unitA = '面积(㎡)'
      }
  }
  }
}
</script>
